home *** CD-ROM | disk | FTP | other *** search
- /* Listing 7 */
-
- /*****************************************************
- LABMASTR.H
-
- Header file containing basic number defs and
- function prototypes for the Lab the Lab Master AD.
-
- Copyright Don Bradley, 1991.
-
- Permission is granted for used of these routines
- in any manner as long as this copyright notice is
- included.
-
- Tested using Quick C 2.5 and MSC 6.0 on a
- Toshiba T5200.
-
- *****************************************************/
-
- #define TRUE 1
- #define FALSE 0
-
- #define LM_BASE 0x02c0
- #define LM_ID 0x4e69
-
- #define DAC0_DATA (LM_BASE + 0x00)
- #define DAC1_DATA (LM_BASE + 0x02)
- #define PRODUCT (LM_BASE + 0x02)
- #define VERSION (LM_BASE + 0x03)
- #define BRD_ENABLE (LM_BASE + 0x04)
- #define IRQ_CONTROL (LM_BASE + 0x05)
- #define IRQ_STATUS (LM_BASE + 0x05)
- #define TIMER_DATA (LM_BASE + 0x06)
- #define TIMER_CONTROL (LM_BASE + 0x08)
- #define ADC_VIRTCHAN (LM_BASE + 0x09)
- #define ADC_CHN_GAIN_ARRAY (LM_BASE + 0x0a)
- #define DIG_OUT (LM_BASE + 0x0b)
- #define DIG_IN (LM_BASE + 0x0b)
- #define DIG_EXP (LM_BASE + 0x0c)
- #define ADC_DATA (LM_BASE + 0x0c)
- #define ADC_LASTCHAN (LM_BASE + 0x0d)
- #define ADC_CONTROL (LM_BASE + 0x0e)
- #define ADC_STATUS (LM_BASE + 0x0e)
- #define DAC_CONTROL (LM_BASE + 0x0f)
- #define DAC_STATUS (LM_BASE + 0x0f)
-
- /* MASK defines */
-
- /* ADC defines */
- #define ADC_FIFO_ENABLE 0x80
- #define ADC_FIFO_DISABLE 0x00
- #define ADC_SINGLE_ENDED 0x00
- #define ADC_DIFFERENTIAL 0x40
- #define ADC_GAIN_1 0x00
- #define ADC_GAIN_2 0x40
- #define ADC_GAIN_4 0x80
- #define ADC_GAIN_8 0xc0
- #define ADC_GAIN_10 0x40
- #define ADC_GAIN_100 0x80
- #define ADC_GAIN_1000 0xc0
- #define ADC_BANK_0 0x00
- #define ADC_BANK_1 0x10
- #define ADC_BANK_2 0x20
- #define ADC_BANK_3 0x30
-
- #define MAX_CHANNELS 16
- #define NON_ADC_VALUE 0x8000
- #define ADC_DMA_BUFFER_LEN 0x1000
- #define ADC_FIFO_SAMPLE_READY 0x40
-
- /* TIMER defines */
- #define TIMER_DIVISOR 10
- // 4MHz
- #define TIMER_F1 4000000L
- // 250KHz
- #define TIMER_F2 (TIMER_F1/TIMER_DIVISOR)
- // 15.625KHz
- #define TIMER_F3 (TIMER_F2/TIMER_DIVISOR)
- // 976.5625Hz
- #define TIMER_F4 (TIMER_F3/TIMER_DIVISOR)
- // 61.03516Hz
- #define TIMER_F5 (TIMER_F4/TIMER_DIVISOR)
-
- /* LabMasterAD function prototypes */
-
- /* labmastr.c */
- int LabMasterAD_Enable(void);
- int LabMasterAD_Disable(void);
- int LabMasterAD_Product(void);
- int LabMasterAD_Version(void);
- void timer_reset(void);
- void timer0_off(void);
- void timer0_on(void);
- void timer5_off(void);
- void timer5_on(void);
- double timer0_setup(double freq);
- void dig_out(int chan, int value);
- int dig_in(int chan);
- void outpwd(unsigned int port, unsigned int value);
- int inpwd(unsigned int port);
-
- /* timerad.c */
- double timerad(double freq);
- void step_timerad(void);
-
- /* adcdma.c */
- int init_adc_dma(unsigned int num_chn,
- long num_samples, double *freq, int dma_chn,
- void (*procfunc)(int));
- void get_next_adc_values(void);
- void terminate_adc_dma(void);
- void clr_adc_dma_buffer(void);
- int adc_dma_done(void);
- long adc_dma_conversion_count(void);
-
- /* adc.c */
- int get_adc(unsigned int chn);
- void disable_adc(void);
- void enable_adc(void);
- int adc_status(void);
-
-